package com.ly.talent.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ly.common.annotation.Log;
import com.ly.common.core.controller.BaseController;
import com.ly.common.core.domain.AjaxResult;
import com.ly.common.enums.BusinessType;
import com.ly.talent.domain.TalentDetail;
import com.ly.talent.service.ITalentDetailService;
import com.ly.common.utils.poi.ExcelUtil;
import com.ly.common.core.page.TableDataInfo;

/**
 * 人才引进信息补充详情Controller
 * 
 * @author sfli
 * @date 2021-02-01
 */
@RestController
@RequestMapping("/talent/talentDetail")
public class TalentDetailController extends BaseController
{
    @Autowired
    private ITalentDetailService talentDetailService;

    /**
     * 查询人才引进信息补充详情列表
     */
    @PreAuthorize("@ss.hasPermi('talent:talentDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(TalentDetail talentDetail)
    {
        startPage();
        List<TalentDetail> list = talentDetailService.selectTalentDetailList(talentDetail);
        return getDataTable(list);
    }

    /**
     * 导出人才引进信息补充详情列表
     */
    @PreAuthorize("@ss.hasPermi('talent:talentDetail:export')")
    @Log(title = "人才引进信息补充详情", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TalentDetail talentDetail)
    {
        List<TalentDetail> list = talentDetailService.selectTalentDetailList(talentDetail);
        ExcelUtil<TalentDetail> util = new ExcelUtil<TalentDetail>(TalentDetail.class);
        return util.exportExcel(list, "talentDetail");
    }

    /**
     * 获取人才引进信息补充详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('talent:talentDetail:query')")
    @GetMapping(value = "/{talentDetailId}")
    public AjaxResult getInfo(@PathVariable("talentDetailId") Long talentDetailId)
    {
        return AjaxResult.success(talentDetailService.selectTalentDetailById(talentDetailId));
    }

    /**
     * 新增人才引进信息补充详情
     */
    @PreAuthorize("@ss.hasPermi('talent:talentDetail:add')")
    @Log(title = "人才引进信息补充详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TalentDetail talentDetail)
    {
        return toAjax(talentDetailService.insertTalentDetail(talentDetail));
    }

    /**
     * 修改人才引进信息补充详情
     */
    @PreAuthorize("@ss.hasPermi('talent:talentDetail:edit')")
    @Log(title = "人才引进信息补充详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TalentDetail talentDetail)
    {
        return toAjax(talentDetailService.updateTalentDetail(talentDetail));
    }

    /**
     * 删除人才引进信息补充详情
     */
    @PreAuthorize("@ss.hasPermi('talent:talentDetail:remove')")
    @Log(title = "人才引进信息补充详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{talentDetailIds}")
    public AjaxResult remove(@PathVariable Long[] talentDetailIds)
    {
        return toAjax(talentDetailService.deleteTalentDetailByIds(talentDetailIds));
    }
}
